/**
 * Generate code from /{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/filter/{{entities@SQL}}SearchContext.java.hbs
 */
package cn.ibizlab.core.ad.filter;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.*;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.annotation.JSONField;

import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.Transient;
import org.springframework.util.ObjectUtils;
import cn.ibizlab.util.filter.QueryWrapperContext;
import cn.ibizlab.util.filter.QueryFilter;
import cn.ibizlab.util.enums.Entities;
import cn.ibizlab.core.ad.domain.SysPerson;

/**
 * 关系型数据实体[SysPerson] 查询条件对象
 *
 * @author generator
 */
@Slf4j
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("人员查询条件对象")
public class SysPersonSearchContext extends QueryWrapperContext<SysPerson> {

    /**
     * 标识EQ
     */
    @JsonProperty("n_id_eq")
    @JSONField(name = "n_id_eq")
    @ApiModelProperty("标识EQ")
    private String idEQ;

    /**
     * 标识IN
     */
    @JsonProperty("n_id_in")
    @JSONField(name = "n_id_in")
    @ApiModelProperty("标识IN")
    private String idIN;

    /**
     * 名称LIKE
     */
    @JsonProperty("n_display_name_like")
    @JSONField(name = "n_display_name_like")
    @ApiModelProperty("名称LIKE")
    private String displayNameLIKE;

    /**
     * DCEQ
     */
    @JsonProperty("n_dc_eq")
    @JSONField(name = "n_dc_eq")
    @ApiModelProperty("DCEQ")
    private String dcEQ;

    /**
     * uid/loginnameEQ
     */
    @JsonProperty("n_uid_eq")
    @JSONField(name = "n_uid_eq")
    @ApiModelProperty("uid/loginnameEQ")
    private String uidEQ;

    /**
     * uid/loginnameIN
     */
    @JsonProperty("n_uid_in")
    @JSONField(name = "n_uid_in")
    @ApiModelProperty("uid/loginnameIN")
    private String uidIN;

    /**
     * 组织机构标识EQ
     */
    @JsonProperty("n_organization_id_eq")
    @JSONField(name = "n_organization_id_eq")
    @ApiModelProperty("组织机构标识EQ")
    private String organizationIdEQ;

    /**
     * 机构编号EQ
     */
    @JsonProperty("n_organization_number_eq")
    @JSONField(name = "n_organization_number_eq")
    @ApiModelProperty("机构编号EQ")
    private String organizationNumberEQ;

    /**
     * 机构编号LEFTLIKE
     */
    @JsonProperty("n_organization_number_leftlike")
    @JSONField(name = "n_organization_number_leftlike")
    @ApiModelProperty("机构编号LEFTLIKE")
    private String organizationNumberLEFTLIKE;

    /**
     * 机构编号LIKE
     */
    @JsonProperty("n_organization_number_like")
    @JSONField(name = "n_organization_number_like")
    @ApiModelProperty("机构编号LIKE")
    private String organizationNumberLIKE;

    /**
     * 组织机构名称LIKE
     */
    @JsonProperty("n_organization_name_like")
    @JSONField(name = "n_organization_name_like")
    @ApiModelProperty("组织机构名称LIKE")
    private String organizationNameLIKE;

    /**
     * 人员编号EQ
     */
    @JsonProperty("n_employee_number_eq")
    @JSONField(name = "n_employee_number_eq")
    @ApiModelProperty("人员编号EQ")
    private String employeeNumberEQ;

    /**
     * 人员编号IN
     */
    @JsonProperty("n_employee_number_in")
    @JSONField(name = "n_employee_number_in")
    @ApiModelProperty("人员编号IN")
    private String employeeNumberIN;

    /**
     * 人员编号LIKE
     */
    @JsonProperty("n_employee_number_like")
    @JSONField(name = "n_employee_number_like")
    @ApiModelProperty("人员编号LIKE")
    private String employeeNumberLIKE;

    /**
     * 类型EQ
     */
    @JsonProperty("n_employee_type_eq")
    @JSONField(name = "n_employee_type_eq")
    @ApiModelProperty("类型EQ")
    private String employeeTypeEQ;

    /**
     * 联系电话EQ
     */
    @JsonProperty("n_telephone_number_eq")
    @JSONField(name = "n_telephone_number_eq")
    @ApiModelProperty("联系电话EQ")
    private String telephoneNumberEQ;

    /**
     * 证件号EQ
     */
    @JsonProperty("n_identification_number_eq")
    @JSONField(name = "n_identification_number_eq")
    @ApiModelProperty("证件号EQ")
    private String identificationNumberEQ;

    /**
     * 证件号IN
     */
    @JsonProperty("n_identification_number_in")
    @JSONField(name = "n_identification_number_in")
    @ApiModelProperty("证件号IN")
    private String identificationNumberIN;

    /**
     * 主部门标识EQ
     */
    @JsonProperty("n_mdepartment_id_eq")
    @JSONField(name = "n_mdepartment_id_eq")
    @ApiModelProperty("主部门标识EQ")
    private String mdepartmentIdEQ;

    /**
     * 主部门EQ
     */
    @JsonProperty("n_mdepartment_name_eq")
    @JSONField(name = "n_mdepartment_name_eq")
    @ApiModelProperty("主部门EQ")
    private String mdepartmentNameEQ;

    /**
     * 主部门LIKE
     */
    @JsonProperty("n_mdepartment_name_like")
    @JSONField(name = "n_mdepartment_name_like")
    @ApiModelProperty("主部门LIKE")
    private String mdepartmentNameLIKE;

    @Override
    public void setContextParentKey(Serializable contextParentKey) {
        super.setContextParentKey(contextParentKey);
        if(Entities.SYS_DEPARTMENT.equals(this.getContextParentEntity())&&contextParentKey!=null)
            this.getFilter().eq("mdepartment_id",contextParentKey);
        if(Entities.SYS_ORGANIZATION.equals(this.getContextParentEntity())&&contextParentKey!=null)
            this.getFilter().eq("organization_id",contextParentKey);
    }

    @Override
    public void setQuery(String query) {
        this.query=query;
        if(!ObjectUtils.isEmpty(query))
            this.getFilter().and(QueryFilter.createQuery().or(QueryFilter.createQuery().like("display_name",query),QueryFilter.createQuery().like("uid",query)));
    }

    @JsonIgnore
    @JSONField(serialize = false)
    @Transient
    @Override
    public QueryWrapper<SysPerson> getSelectCond() {
        QueryWrapper<SysPerson> queryWrapper = super.getSelectCond();
        return queryWrapper;
    }
}